<?php
/* @var $this IptvprogramListController */
/* @var $model IptvprogramList */
/* @var $form CActiveForm */
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'iptvprogram-list-form',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller code.
// See class documentation of CActiveForm for details on this.
	'enableAjaxValidation'=>false,
	'htmlOptions'=>array('enctype'=>'multipart/form-data'),
)); ?>

	<p class="note">
	<?php echo Yii::t('base','Fields with <span class="required">*</span> are required.');?>
	</p>

	<?php echo $form->errorSummary($model);
	$categoryarr=array('1'=>'动作',
				    '2'=>'冒险',
					'3'=>'喜剧',	
					'4'=>'爱情',
					'5'=>'战争',
				    '6'=>'恐怖',
					'7'=>'犯罪',
					'8'=>'悬疑',
					'9'=>'惊悚',
					'10'=>'武侠',
					'11'=>'科幻',
					'12'=>'音乐',
					'13'=>'歌舞',
					'14'=>'动画',
					'15'=>'奇幻',
					'16'=>'家庭',
				    '17'=>'剧情',
					'18'=>'伦理',
					'19'=>'记录',
					'20'=>'历史',
					'21'=>'传记'
	);

	$languagearr=array('1'=>'普通话','2'=>'广东话 ','3'=>'英语','4'=>'日语', '5'=>'韩语', '6'=>'其他');
	$countryarr=array('1'=>'大陆', '2'=>'香港', '3'=>'台湾', '4'=>'日本', '5'=>'韩国', '6'=>'美国', '7'=>'英国' ,'8'=>'其他');
	$packagearr=array('1'=>'基础套餐','2'=>'中级套餐','3'=>'高级套餐');
	$classificationarr=array('Exempt (E)', 'General (G)', 'Parental Guidance (PG)', 'Mature (M)', 'Mature Accompanied (MA15+)', 'Restricted (R18+)', 'Restricted (X18+))');
	$score_ratingarr=array('0','1','2','3','4','5');
	$listarr=array(Yii::t('base','NO'),Yii::t('base','YES'));
	//$latestarr=array(Yii::t('base','NO'),Yii::t('base','YES'));
	//$populararr=array(Yii::t('base','NO'),Yii::t('base','YES'));
	//$recommendarr=array(Yii::t('base','NO'),Yii::t('base','YES'));
	$deletearr=array(Yii::t('base','Hide'),Yii::t('base','Exist'));
	$latestarr=array('1'=>'最新');
	$populararr=array('1'=>'热播');
	$recommendarr=array('1'=>'推荐');
	?>



	<div class="row">
	<?php echo $form->labelEx($model,'title'); ?>
	<?php echo $form->textField($model,'title',array('size'=>50,'maxlength'=>300)); ?>
	<?php echo $form->error($model,'title'); ?>
	</div>

	<div class="row">
	<?php echo $form->labelEx($model,'year'); ?>
	<?php echo $form->textField($model,'year'); ?>
	<?php echo $form->error($model,'year'); ?>
	</div>

	<div class="row">
	<?php echo $form->labelEx($model,'type_id'); ?>

	<?php echo $form->dropDownlist($model,'type_id',IptvprogramList::model()->getType());?>
	<?php echo $form->error($model,'type_id'); ?>
	</div>

	<div class="row">
	<?php echo $form->labelEx($model,'category'); ?>
	<?php
	$arr = explode('|',$model->category);//存入数据库中的数组
	$k=0;
	for($i=1; $i<=count($categoryarr); $i++){
		for($j=0; $j<count($arr); $j++){
			if($arr[$j] == array_search($categoryarr[$i],$categoryarr)){
				$k++;
				?>
		<input type="checkbox" name="category[]" checked="checked"
			value="<?php echo array_search($categoryarr[$i],$categoryarr);?>" />
			<?php echo $categoryarr[$i];?>
			<?php
			}

		}
		if(($i+1)%5 == 0&&$i>=4){
			echo '</br >';
		}
		if($k == 0){
			?>
		<input type="checkbox" name="category[]"
			value="<?php echo array_search($categoryarr[$i],$categoryarr);?>" />
			<?php echo $categoryarr[$i];?>
			<?php
		}
		$k=0;
	}
	?>
	<?php echo $form->error($model,'category'); ?>
	</div>





	<div class="row">
	<?php echo $form->labelEx($model,'country'); ?>
	<?php echo $form->dropDownlist($model,'country',$countryarr); ?>
	<?php echo $form->error($model,'country'); ?>
	</div>

	<div class="row">
	<?php echo $form->labelEx($model,'language'); ?>
	<?php echo $form->dropDownlist($model,'language',$languagearr); ?>
	<?php echo $form->error($model,'language'); ?>
	</div>

 <div class="row">
	<?php echo $form->labelEx($model,'package_id'); ?>
	<?php
	$arr = explode('|',$model->package_id);
	$k=0;
	for($i=1; $i<=count($packagearr); $i++){
		for($j=0; $j<count($arr); $j++){
			if($arr[$j] == array_search($packagearr[$i],$packagearr)){
				$k++;
				?>
		<input type="checkbox" name="package_id[]" checked="checked"
			value="<?php echo array_search($packagearr[$i],$packagearr);?>" />
			<?php echo $packagearr[$i];?>
			<?php
			}

		}
		if(($i+1)%5 == 0&&$i>=4){
			echo '</br >';
		}
		if($k == 0){
			?>
		<input type="checkbox" name="package_id[]"
			value="<?php echo array_search($packagearr[$i],$packagearr);?>" />
			<?php echo $packagearr[$i];?>
			<?php
		}
		$k=0;
	}
	?>
	<?php echo $form->error($model,'package_id'); ?>
	</div>
 
	<div class="row">
	<?php echo $form->labelEx($model,'actor'); ?>
	<?php echo $form->textField($model,'actor',array('size'=>50,'maxlength'=>50)); ?>
	<?php echo $form->error($model,'actor'); ?>
	</div>

	<div class="row">
	<?php echo $form->labelEx($model,'duration'); ?>
	<?php echo $form->textField($model,'duration'); ?>
	<?php echo $form->error($model,'duration'); ?>
	</div>

	<div class="row">
	<?php echo $form->labelEx($model,'classification'); ?>
	<?php echo $form->dropDownList($model,'classification',$classificationarr); ?>
	<?php echo $form->error($model,'classification'); ?>
	</div>

	<div class="row">
	<?php echo $form->labelEx($model,'score_rating'); ?>
	<?php echo $form->dropDownList($model,'score_rating',$score_ratingarr); ?>
	<?php echo $form->error($model,'score_rating'); ?>
	</div>

	<div class="row">
	<?php echo $form->labelEx($model,'video_link'); ?>
	<?php echo $form->textField($model,'video_link',array('size'=>30,'maxlength'=>50)); ?>
	<?php echo $form->error($model,'video_link'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'is_have_list'); ?>
		<?php echo $form->dropDownList($model,'is_have_list',$listarr); ?>
		<?php echo $form->error($model,'is_have_list'); ?>
	</div>
	<div class="row">
	<?php echo $form->labelEx($model,'video_info'); ?>
	<?php echo $form->textArea($model,'video_info',array('size'=>250,'maxlength'=>300)); ?>
	<?php echo $form->error($model,'video_info'); ?>
	</div>
	
	<div class="row">
	<?php echo $form->labelEx($model,'pic_link_large'); ?>
	<?php echo $form->textField($model,'pic_link_large',array('size'=>300,'maxlength'=>500)); ?>
	<?php //echo '<img src="'.$model->pic_link_large.'"    width="20%"/>'; ?>
	<?php echo CHtml::activeFileField($model,'pic_link_large'); ?>
	
	<?php if(!$model->isNewRecord){?>
	<input type="hidden" name="pic_link_large2" id="hiddenField"    value="<?php echo $model->pic_link_large;?>"/>
	<?php }?>
	<?php echo $form->error($model,'pic_link_large'); ?>
	</div>
	
	<div class="row">
	<?php echo $form->labelEx($model,'pic_link_small'); ?>
	<?php echo $form->textField($model,'pic_link_small',array('size'=>300,'maxlength'=>500)); ?>
	<?php //echo '<img src="'.$model->pic_link_small.'"    width="20%"/>'; ?>
	<?php echo CHtml::activeFileField($model,'pic_link_small'); ?>
	<?php if(!$model->isNewRecord){?>
	<input type="hidden" name="pic_link_small2" id="hiddenField"    value="<?php echo $model->pic_link_small;?>"/>
	<?php }?>
	<?php echo $form->error($model,'pic_link_small'); ?>
	</div>

	


	<div class="row">
	<?php echo $form->labelEx($model,'play_count'); ?>
	<?php echo $form->textField($model,'play_count'); ?>
	<?php echo $form->error($model,'play_count'); ?>
	</div>
<!--
	<div class="row">
		<?php echo $form->labelEx($model,'is_delete'); ?>
		<?php echo $form->dropDownList($model,'is_delete',$deletearr); ?>
		<?php echo $form->error($model,'is_delete'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'remark'); ?>
		<?php echo $form->textField($model,'remark',array('size'=>60,'maxlength'=>500)); ?>
		<?php echo $form->error($model,'remark'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'create_user'); ?>
		<?php echo $form->textField($model,'create_user',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'create_user'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'create_time'); ?>
		<?php echo $form->textField($model,'create_time'); ?>
		<?php echo $form->error($model,'create_time'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'update_user'); ?>
		<?php echo $form->textField($model,'update_user',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'update_user'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'update_time'); ?>
		<?php echo $form->textField($model,'update_time'); ?>
		<?php echo $form->error($model,'update_time'); ?>
	</div>
-->
	<script>
	window.onload=function(){setTimeout("Check()")}
	function Check()
	{
	
		var latest = $("#lat").val();
		var popular = $("#pop").val();
		var recommend=$("#rec").val();
		var lat=document.getElementById('latest');
		var pop=document.getElementById('popular');
		var rec=document.getElementById('recommend');
		if(latest==1)
		{
		   lat.checked = true
		}
		if(popular==1)
		{
		   pop.checked = true
		}
		if(recommend==1)
		{
		   rec.checked = true
		}
		
	
	}
	</script>
    <div class="row">
      <?php echo $form->labelEx($model,Yii::t('base','Status')); ?>
      <input type='hidden' id='lat' value='<?php echo $model->latest?>'/>
      <input type='hidden' id='pop' value='<?php echo $model->popular?>' />
      <input type='hidden' id='rec' value='<?php echo $model->recommend?>' />
         <input type="checkbox" id='latest' name="late" value='<?php echo "1"?>' /> <?php echo '最新';?>
         <input type="checkbox" id='popular' name="popu"  value='<?php echo "1"?>' /> <?php echo '热播';?>
         <input type="checkbox" id='recommend' name="reco" value='<?php echo "1"?>' /> <?php echo '推荐';?>
    </div>
    
	<div class="row buttons">
	<?php echo CHtml::submitButton($model->isNewRecord ? Yii::t('base','Create') : Yii::t('base','Save')); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->